package org.achao.task;

import org.achao.service.impl.TestService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;
import org.springframework.stereotype.Service;

import java.util.Date;

/**
 * @author achao
 * @description 定时调度组件
 * @date 2023/9/27 0:05
 */
@Service
public class MyTask {

    @Autowired
    private TestService testService;
    @Scheduled(cron = "0/2 * * * * ?")
    public void executeTask() {
        System.out.println("定时任务:" + new Date());
        String test = testService.test();
        System.out.println(test);
    }
}
